import React from 'react'
import './app.scss'
class App extends React.Component {
    constructor() {
        super()
        this.state={
            num:0,
            arr:['红','绿','蓝','紫','橙'],
            color:['red','green','blue','purple','orange']
        }
    }
    render() {
        const {num,arr,color} = this.state
        return <div className='facth'>
            <div className='btn'>
                {
                    arr.map((item,index)=>{
                        return <button key={index} onClick={()=>this.setState({num:index})}>
                            {item}
                        </button>
                    })
                }
            </div>
            <div className='box'> 
                <div style={{ background:color[num] }}></div>
            </div>
        </div>
    }
}
export default App